import matplotlib.pyplot as plt
from gen import generate_data
from alg import find_content_children

plt.rcParams['font.sans-serif'] = ['SimHei']  # 设置中文字体为黑体
plt.rcParams['axes.unicode_minus'] = False    # 正常显示负号

def visualize():
    g, s = generate_data()
    satisfied = find_content_children(g, s)
    plt.figure(figsize=(10, 5))
    plt.bar(range(len(g)), sorted(g), label='孩子胃口值')
    plt.bar(range(len(s)), sorted(s), alpha=0.5, label='饼干尺寸')
    plt.title(f"最多能满足的孩子数: {satisfied}")
    plt.xlabel("编号")
    plt.ylabel("值")
    plt.legend()
    plt.show()

if __name__ == "__main__":
    visualize()